package com.ktjy.ch15.service.impl;

import com.ktjy.ch15.entity.SysRole;
import com.ktjy.ch15.mapper.SysRoleMapper;
import com.ktjy.ch15.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("sysRoleService")
public class SysRoleServiceImpl implements SysRoleService {

    @Autowired
    private SysRoleMapper sysRoleMapper;

    @Override
    public List<SysRole> findAll() {
        return sysRoleMapper.getAll();
    }

    @Override
    public boolean save(SysRole sysRole) {
        return sysRoleMapper.insert(sysRole) > 0;
    }

    @Override
    public SysRole findById(Long id) {
        return sysRoleMapper.getById(id);
    }

    @Override
    public boolean update(SysRole sysRole) {
        return sysRoleMapper.update(sysRole) > 0;
    }

    @Override
    public boolean delete(Long id) {
        return sysRoleMapper.delete(id) > 0;
    }

    @Override
    public SysRole findByCode(String code) {
        return sysRoleMapper.getByCode(code);
    }

    @Override
    public boolean count(Long roleId) {
        return sysRoleMapper.count(roleId) > 0;
    }
}
